/*
 *  Copyright 2010 UPF Telecos 4th group G.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package edu.upf.messages;

import edu.upf.content.DescriptionContent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Class that implements a message payload for sending a search result
 * @author netjois
 */
public class SearchResult implements Serializable{

    private List<DescriptionContent> contentList;
    private String queryID;

    /**
     * Constructor, receives the associated query to the result
     * @param queryID
     */
    public SearchResult(String queryID){
        contentList = new ArrayList();
        this.queryID=queryID;
    }

    /**
     * Gets the content object inside the results. The parameter
     * indicates what content of the list get.
     * @param id
     * @return
     */
    public DescriptionContent getContent(int id) {
        return contentList.get(id);
    }

    /**
     * Gets the size of the content list of the result
     * @return
     */
    public int contentLength(){
        return contentList.size();
    }

    public void setList(List contentList){
        this.contentList=contentList;
    }

    public void addList(List addedContentList){
        Iterator i=addedContentList.iterator();
        while(i.hasNext()){
            DescriptionContent dc =(DescriptionContent) i.next();
            contentList.add(dc);
        }
    }

    public List getList(){
        return contentList;
    }

    public String getQueryID(){
        return queryID;
    }

    public void setQueryID(String queryID){
        this.queryID=queryID;
    }
}
